import { ICondition } from '../../../interfaces';
import service from './service';

/**
 * 调用java dsd服务
 * @param systemid 产品systemid
 * @param refsystemid 产品refsystemid
 * @param modelid 服务名
 * @param condition 参数
 * @returns 服务返回结果
 * @example javadsd(url, systemid, refsystemid, modelid, condition);
 */
export default function javadsd<T>(systemid: string, refsystemid: string, modelid: string, condition: ICondition) {
	if (!condition) {
		condition = {
			paging: {
				index: 1,
				size: 12
			},
			param: {},
			sort: {}
		} as any;
	}
	if (!condition.paging) {
		condition.paging = {
			index: 1,
			size: 12
		};
	}
	if (!condition.param) {
		condition.param = {} as any;
	}
	if (!condition.sort) {
		condition.sort = {};
	}
	const msg = {
		condition,
		modelid,
		refsystemid,
		systemid
	};
	return service<T>('dataservice.javadsd', msg);
}
